package com.evil.common.core.util;

import cn.hutool.core.util.RandomUtil;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;


public class PasswordUtil {

    public static String getSecretPassword(String password, String salt) {
        if (StringUtils.isBlank(password) || StringUtils.isBlank(salt)) {
            return null;
        }
        String newPass = DigestUtils.sha384Hex(password);
        newPass = DigestUtils.sha384Hex(newPass + salt);
        return newPass;
    }

    public static String getSalt() {
        return RandomUtil.randomString(6);
    }

}
